package com.winit.schedule.core.repository.entity;

import java.io.Serializable;

import com.winit.schedule.core.model.TaskID;
import com.winit.schedule.core.repository.constants.AlarmStrategy;
import com.winit.schedule.core.repository.constants.AlarmType;
import com.winit.schedule.core.repository.constants.TaskStatus;
import com.winit.schedule.core.task.TaskInterfaceType;

public class TaskEntity implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = -2994980656571165295L;

    private TaskID            taskId;

    private String            taskGroup;

    private String            taskName;

    private TaskInterfaceType interfaceType;

    private String            runStartTime;

    private String            runEndTime;

    /**
     * 启动后立即执行一次
     */
    private boolean           immediatelyRun;

    private int               maxThreads;

    private int               threadsOfRegion;

    /**
     * 任务项，英文逗号分隔
     */
    private String            taskItem;

    /**
     * 白名单
     */
    private String            ipWhiteList;

    /**
     * 任务参数
     */
    private String            taskParameter;

    /**
     * 任务状态
     */
    private TaskStatus        taskStatus       = TaskStatus.INIT;

    /**
     * 每次数据处理完毕后线程休眠时间
     */
    private long              sleepTimeInterval;

    /**
     * 每次抓取数据的数量
     */
    private int               eachFetchDataNum;

    /**
     * 数据处理的批量大小
     */
    private int               batchDealNum     = 1;

    /**
     * 没有抓取到数据时，线程休眠时长，单位：毫秒
     */
    private long              sleepTimeNoData;

    /**
     * 优先级 (数值越大 优先级越低)
     */
    protected int             priority         = 0;

    /**
     * 告警,告警接受邮件地址
     */
    private String            alarmTo;

    /**
     * 告警类型
     */
    private AlarmType         alarmType        = AlarmType.EMAIL;

    /**
     * 告警策略
     */
    private AlarmStrategy     alarmStrategy    = AlarmStrategy.DEFAULT;

    /**
     * 是否自动恢复状态异常的任务项;1:自动恢复，0：不自动恢复
     */
    private boolean           autoRecovery;

    public TaskEntity(){
    }

    public TaskEntity(String taskGroup, String taskName, TaskInterfaceType interfaceType){
        super();
        this.taskId = new TaskID(taskGroup + "$" + taskName);
        this.taskGroup = taskGroup;
        this.taskName = taskName;
        this.interfaceType = interfaceType;
    }

    public TaskID getTaskId() {
        return taskId;
    }

    public void setTaskId(TaskID taskId) {
        this.taskId = taskId;
    }

    public String getTaskGroup() {
        return taskGroup;
    }

    public void setTaskGroup(String taskGroup) {
        this.taskGroup = taskGroup;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getRunStartTime() {
        return runStartTime;
    }

    public void setRunStartTime(String runStartTime) {
        this.runStartTime = runStartTime;
    }

    public String getRunEndTime() {
        return runEndTime;
    }

    public void setRunEndTime(String runEndTime) {
        this.runEndTime = runEndTime;
    }

    public int getMaxThreads() {
        return maxThreads;
    }

    public int getThreadsOfRegion() {
        return threadsOfRegion;
    }

    public void setThreadsOfRegion(int threadsOfRegion) {
        this.threadsOfRegion = threadsOfRegion;
    }

    public void setMaxThreads(int maxThreads) {
        this.maxThreads = maxThreads;
    }

    public String getTaskItem() {
        return taskItem;
    }

    public void setTaskItem(String taskItem) {
        this.taskItem = taskItem;
    }

    public String getIpWhiteList() {
        return ipWhiteList;
    }

    public void setIpWhiteList(String ipWhiteList) {
        this.ipWhiteList = ipWhiteList;
    }

    public String getTaskParameter() {
        return taskParameter;
    }

    public void setTaskParameter(String taskParameter) {
        this.taskParameter = taskParameter;
    }

    public TaskStatus getTaskStatus() {
        return taskStatus;
    }

    public void setTaskStatus(TaskStatus taskStatus) {
        this.taskStatus = taskStatus;
    }

    public int getEachFetchDataNum() {
        return eachFetchDataNum;
    }

    public void setEachFetchDataNum(int eachFetchDataNum) {
        this.eachFetchDataNum = eachFetchDataNum;
    }

    public long getSleepTimeNoData() {
        return sleepTimeNoData;
    }

    public void setSleepTimeNoData(long sleepTimeNoData) {
        this.sleepTimeNoData = sleepTimeNoData;
    }

    public long getSleepTimeInterval() {
        return sleepTimeInterval;
    }

    public void setSleepTimeInterval(long sleepTimeInterval) {
        this.sleepTimeInterval = sleepTimeInterval;
    }

    public TaskInterfaceType getInterfaceType() {
        return interfaceType;
    }

    public void setInterfaceType(TaskInterfaceType interfaceType) {
        this.interfaceType = interfaceType;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public boolean isImmediatelyRun() {
        return immediatelyRun;
    }

    public void setImmediatelyRun(boolean immediatelyRun) {
        this.immediatelyRun = immediatelyRun;
    }

    public String getAlarmTo() {
        return alarmTo;
    }

    public void setAlarmTo(String alarmTo) {
        this.alarmTo = alarmTo;
    }

    public AlarmType getAlarmType() {
        return alarmType;
    }

    public void setAlarmType(AlarmType alarmType) {
        this.alarmType = alarmType;
    }

    public AlarmStrategy getAlarmStrategy() {
        return alarmStrategy;
    }

    public void setAlarmStrategy(AlarmStrategy alarmStrategy) {
        this.alarmStrategy = alarmStrategy;
    }

    public boolean isAutoRecovery() {
        return autoRecovery;
    }

    public void setAutoRecovery(boolean autoRecovery) {
        this.autoRecovery = autoRecovery;
    }

    public int getBatchDealNum() {
        return batchDealNum;
    }

    public void setBatchDealNum(int batchDealNum) {
        this.batchDealNum = batchDealNum;
    }

}
